package model.stats;

import java.util.Iterator;
import java.util.LinkedList;
/**
 * This class applies modifications to the StatsContanier that are temporary, that is
 * they only last a fixed number of cycles before they are removed. The apply method adds the modifiers
 * to the stats. Before applying to stats, the modifiers have to be defined. An addXXXMod method loads a new
 * modifier that will be applied to XXX stat. All the modifiers have to be loaded before 
 * the SStatsTempMods is applied() to a statsContainer.
 * @author dkorytov
 *
 */
public class StatsTempMods {
	
	LinkedList<TempModifier> modifiers = new LinkedList<TempModifier>();
	
	public StatsTempMods() {}
	/**
	 * applies the loaded modifiers to the statsContainer.
	 * @param stats
	 */
	public void apply(StatsContainer stats){
		Iterator<TempModifier> iter = modifiers.iterator();
		while(iter.hasNext()){
			iter.next().apply(stats);
		}
	}
	
	public void addStrenghtMod(Integer amount, Integer duration){
		modifiers.add(
			new TempModifier(amount, duration){
				public void apply(StatsContainer stats){
					stats.addTempModStrength(getMagnitude(), getDuration());
				}
			}
		);
	}
	
	public void addAgilityMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModAgility(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addIntellectMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModIntellect(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addHardinessMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModHardiness(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addMovmentMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModMovement(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addMaxHealthMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModMaxHealth(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addMaxManaMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModMaxMana(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addOffenseMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModOffense(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addDefenseMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModDefense(getMagnitude(), getDuration());
					}
				}
			);
	}
	public void addArmorMod(Integer amount, Integer duration){
		modifiers.add(
				new TempModifier(amount, duration){
					public void apply(StatsContainer stats){
						stats.addTempModArmor(getMagnitude(), getDuration());
					}
				}
			);
		
	}
	public void addVisionMod(Integer amount, Integer duration){
		modifiers.add(
			new TempModifier(amount, duration){
				public void apply(StatsContainer stats){
					stats.addTempModVision(getMagnitude(), getDuration());
				}
			}
		);
	}


}
